
{{template "header.html" .}}

<ul class="breadcrumb">
  <li><a href="/">Streams</a> <span class="divider">/</span></li>
  <li class="active">{{.Topic}}</li>
</ul>

<div class="row-fluid"><div class="span12">
<h1>Topic: {{.Topic}}</h1>
</div></div>

<div class="row-fluid"><div class="span2">
    <form action="/delete_topic" method="GET">
        <input type="hidden" name="topic" value="{{.Topic}}">
        <button class="btn btn-medium btn-danger" type="submit">Delete Topic</button>
    </form>
</div></div>

<div class="row-fluid"><div class="span8">
<h3>Topic Message Queue</h3>
<table class="table table-bordered table-condensed">
    <tr>
        <th>nsqd Host</th>
        <th>Depth</th>
        <th>Memory + Disk</th>
        <th>Messages</th>
        <th>Channels</th>
    </tr>
    {{range .TopicHostStats }}
    <tr>
        <td>{{.HostAddress}}</td>
        <td>{{.Depth | commafy}}</td>
        <td>{{.MemoryDepth | commafy}} + {{.BackendDepth | commafy}}</td>
        <td>{{.MessageCount | commafy}}</td>
        <td>{{.ChannelCount}}</td>
    </tr>
    {{ end }}
    {{ with .GlobalTopicStats }} 
    <tr class="info">
        <td>Total:</td>
        <td>{{.Depth | commafy}}</td>
        <td>{{.MemoryDepth | commafy}} + {{.BackendDepth | commafy}}</td>
        <td>{{.MessageCount | commafy}}</td>
        <td>{{.ChannelCount}}</td>
    </tr>
    {{ end }}
</table>
</div></div>

<div class="row-fluid"><div class="span12">
<h3>Channel Message Queues</h3>
{{ if not .ChannelStats }}
    <p><span class="label label-warning">Warning</span> no channels have been created. Messages will queue at the topic
        message queue until a client connects.</p>
{{else}}
<table class="table table-bordered table-condensed">
    <tr>
        <th>Channel</th>
        <th>Depth</th>
        <th>Memory + Disk</th>
        <th>In-Flight</th>
        <th>Deferred</th>
        <th>Requeued</th>
        <th>Timed Out</th>
        <th>Messages</th>
        <th>Connections</th>
    </tr>

{{range $c := .ChannelStats}}
    <tr >
        <th><a href="/topic/{{$c.Topic}}/{{$c.ChannelName | urlquery}}">{{$c.ChannelName}}</a> 
            {{if $c.Paused}}<span class="label label-important">paused</span>{{end}}
            </th>
        <td>{{$c.Depth | commafy}}</td>
        <td>{{$c.MemoryDepth | commafy}} + {{$c.BackendDepth | commafy}}</td>
        <td>{{$c.InFlightCount | commafy}}</td>
        <td>{{$c.DeferredCount | commafy}}</td>
        <td>{{$c.RequeueCount | commafy}}</td>
        <td>{{$c.TimeoutCount | commafy}}</td>
        <td>{{$c.MessageCount | commafy}}</td>
        <td>{{$c.ClientCount}}</td>
    </tr>
{{ end }}
</table>
{{end}}
</div></div>

{{template "footer.html" .}}


